<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="fragments/easyui_insdep_head :: easyui_insdep_head" th:with="title='出货记录'">
</head>
<body>

<table id="tt" class="easyui-datagrid" style="width:100%;height:100%"
       url="/shipment/shipmentRecord" pageList='[1,10,20,30,50]' singleSelect="true" toolbar="#tb"
       method="get" rownumbers="true" pagination="true">
    <thead>
    <tr>
        <th field="shiptRecId" width="80" >出货记录编号</th>
        <th field="wareNum" width="80" >出货项目数</th>
        <th field="totalNum" width="80" >商品总件数</th>
        <th field="totalPrice" width="80" >总出货价</th>
        <th field="shiptRecTime" width="200" data-options="formatter:function(value){return new Date(value).format('yyyy-MM-dd hh:mm:ss');}">出货时间</th>
        <th field="staffName" width="160">出货账号</th>
    </tr>
    </thead>
</table>

<div id="tb" style="padding:3px">
    <span>开始时间:</span>
    <input id="from" class="easyui-datebox" style="line-height:26px;border:1px solid #ccc"/>
    <span>结束时间:</span>
    <input id="to" class="easyui-datebox" style="line-height:26px;border:1px solid #ccc"/>
    <span>出货账号:</span>
    <input id="staffName" style="line-height:26px;border:1px solid #ccc"/>
    <a href="#" class="easyui-linkbutton" plain="true" onclick="doSearch()">查找</a>
    <a href="#" class="easyui-linkbutton" plain="true" onclick="doReSet()">重置</a>
    <script type="text/javascript">
        //<![CDATA[
        $(function () {
            $("#tt").datagrid({
                onDblClickRow : function (index, row) {
                    windowOpen("出货记录项", "/shipment/pages/shipmentItemPage", row);
                }
            });

            var pager = $('#tt').datagrid().datagrid('getPager');	// get the pager of datagrid

            pager.pagination({
                buttons: [{
                    iconCls: 'icon-edit',
                    handler: function () {
                        row = $("#tt").datagrid('getSelected');

                        if (row == null) {
                            $.messager.alert('警告', '请选中需要重做的出货记录', 'info');
                            return;
                        }

                        windowOpen("重做出货记录", "/shipment/pages/reShipmentPage", row, true);
                    }
                }]
            });
        });

        Date.prototype.format = function(format) {
            var date = {
                "M+": this.getMonth() + 1,
                "d+": this.getDate(),
                "h+": this.getHours(),
                "m+": this.getMinutes(),
                "s+": this.getSeconds(),
                "q+": Math.floor((this.getMonth() + 3) / 3),
                "S+": this.getMilliseconds()
            };
            if (/(y+)/i.test(format)) {
                format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
            }
            for (var k in date) {
                if (new RegExp("(" + k + ")").test(format)) {
                    format = format.replace(RegExp.$1, RegExp.$1.length == 1
                        ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
                }
            }
            return format;
        }
        function doSearch() {
            $('#tt').datagrid('load', {
                from: $('#from').val(),
                to: $('#to').val(),
                staffName: $('#staffName').val(),
            });
        }
        function doReSet() {
            $('#from').datebox('setValue', "");
            $('#to').datebox('setValue', "");
            $('#staffName').val("");
            doSearch();
        }
        //]]>
    </script>
</div>

<div id="ajaxWin" class="easyui-window" title=""
     data-options="modal:true,collapsible:true,closed:true,maximizable:false,minimizable:false,resizable:false"
     style="width:850px;height:500px;overflow: hidden">
    <iframe id="frame" name="frame" frameborder="0" style="height:100%;width:100%; "/>
</div>
<script type="text/javascript">
    //<![CDATA[
    $(function () {
        $("#ajaxWin").window({
            onClose: function () {
                $("#tt").datagrid('reload');
            }
        });
    });
    //]]>
</script>


<script type="text/javascript">
    //<![CDATA[
    function windowOpen(title, ajax_url, row, isMax) {
        $('#ajaxWin').panel({title: title}).panel('restore');

        if (isMax) {
            $('#ajaxWin').panel('maximize');
        } else {
            $('#ajaxWin').panel('restore');
        }

        $("#frame").attr("src", ajax_url + "?shipmentRecordId=" + row.shiptRecId);

        $('#ajaxWin').window('open');
    }

    //]]>
</script>


</body>
</html>